//
//  lnddNetworkTools.swift
//  liaoningdangdai
//
//  Created by 邵禹曦 on 2019/11/22.
//  Copyright © 2019 白雨桐. All rights reserved.
//

import UIKit


// MARK: - 直供申购模块
extension NetworkTools {
    
    
    /// 发行商品查询
    /// 2.1
    /// 加载数据字典数组
    ///
    /// - parameter since_id:   返回ID比since_id大的微博（即比since_id时间晚的微博），默认为0
    /// - parameter max_id:     返回ID小于或等于max_id的微博，默认为0
    /// - parameter completion: 完成回调[list: 微博字典数组/是否成功]
    
    func issue_commodity_query(session_id : String?, code : Array<Any>, finished : @escaping(_ result : [String : AnyObject]?, _ error : NSError?) -> ()) {
           
        if session_id == nil {
            print("请登陆")
            return
        }
        
        // 1.获取请求的URLString
           let urlString = "http://39.98.72.212:8006/index.php/Admin/Inter/index"
           
           // 2.获取请求的参数
        let parameters = ["method" : "phone", "xmlname" : "issue_commodity_query","model":"直供申购手机端","data": code ] as [String : Any]
           
           // 3.发送网络请求
        request(methodType: .GET, URLString: urlString, parameters: parameters) { (result, error) -> () in
            finished(result as? [String : AnyObject], error as NSError?)
           }
       }
    
    
    /// 获取最大可申购量
    /// 2.2
    /// 加载数据字典数组
    ///
    /// - parameter since_id:   返回ID比since_id大的微博（即比since_id时间晚的微博），默认为0
    /// - parameter max_id:     返回ID小于或等于max_id的微博，默认为0
    /// - parameter completion: 完成回调[list: 微博字典数组/是否成功]
    
    func issue_purchase_maxqty_query(session_id : String?, code : Array<Any>, finished : @escaping(_ result : [String : AnyObject]?, _ error : NSError?) -> ()) {
           
        if session_id == nil {
            print("请登陆")
            return
        }
        
        // 1.获取请求的URLString
           let urlString = "http://39.98.72.212:8006/index.php/Admin/Inter/index"
           
           // 2.获取请求的参数
        let parameters = ["method" : "phone", "xmlname" : "issue_purchase_maxqty_query","model":"直供申购手机端","data": code ] as [String : Any]
           
           // 3.发送网络请求
        request(methodType: .GET, URLString: urlString, parameters: parameters) { (result, error) -> () in
            finished(result as? [String : AnyObject], error as NSError?)
           }
       }
    
    
    /// 发行申购
    /// 2.3
    /// 加载数据字典数组
    ///
    /// - parameter since_id:   返回ID比since_id大的微博（即比since_id时间晚的微博），默认为0
    /// - parameter max_id:     返回ID小于或等于max_id的微博，默认为0
    /// - parameter completion: 完成回调[list: 微博字典数组/是否成功]
    
    func issue_apply(session_id : String?, code : Array<Any>, finished : @escaping(_ result : [String : AnyObject]?, _ error : NSError?) -> ()) {
           
        if session_id == nil {
            print("请登陆")
            return
        }
        
        // 1.获取请求的URLString
           let urlString = "http://39.98.72.212:8006/index.php/Admin/Inter/index"
           
           // 2.获取请求的参数issue_apply
        let parameters = ["method" : "phone", "xmlname" : "issue_commodity_query","model":"直供申购手机端","data": code ] as [String : Any]
           
           // 3.发送网络请求
        request(methodType: .GET, URLString: urlString, parameters: parameters) { (result, error) -> () in
            finished(result as? [String : AnyObject], error as NSError?)
           }
       }
    
    
    
    /// 撤销申购
    /// 2.4
    /// 加载数据字典数组
    ///
    /// - parameter since_id:   返回ID比since_id大的微博（即比since_id时间晚的微博），默认为0
    /// - parameter max_id:     返回ID小于或等于max_id的微博，默认为0
    /// - parameter completion: 完成回调[list: 微博字典数组/是否成功]
    
    func issue_deletepurchase(session_id : String?, code : Array<Any>, finished : @escaping(_ result : [String : AnyObject]?, _ error : NSError?) -> ()) {
           
        if session_id == nil {
            print("请登陆")
            return
        }
        
        // 1.获取请求的URLString
           let urlString = "http://39.98.72.212:8006/index.php/Admin/Inter/index"
           
           // 2.获取请求的参数
        let parameters = ["method" : "phone", "xmlname" : "issue_deletepurchase","model":"直供申购手机端","data": code ] as [String : Any]
           
           // 3.发送网络请求
        request(methodType: .GET, URLString: urlString, parameters: parameters) { (result, error) -> () in
            finished(result as? [String : AnyObject], error as NSError?)
           }
       }
    
    
    
    /// 发行申购查询
       /// 2.5
       /// 加载数据字典数组
       ///
       /// - parameter since_id:   返回ID比since_id大的微博（即比since_id时间晚的微博），默认为0
       /// - parameter max_id:     返回ID小于或等于max_id的微博，默认为0
       /// - parameter completion: 完成回调[list: 微博字典数组/是否成功]
       
       func issue_apply_query(session_id : String?, code : Array<Any>, finished : @escaping(_ result : [String : AnyObject]?, _ error : NSError?) -> ()) {
              
           if session_id == nil {
               print("请登陆")
               return
           }
           
           // 1.获取请求的URLString
              let urlString = "http://39.98.72.212:8006/index.php/Admin/Inter/index"
              
              // 2.获取请求的参数
           let parameters = ["method" : "phone", "xmlname" : "issue_apply_query","model":"直供申购手机端","data": code ] as [String : Any]
              
              // 3.发送网络请求
           request(methodType: .GET, URLString: urlString, parameters: parameters) { (result, error) -> () in
               finished(result as? [String : AnyObject], error as NSError?)
              }
          }
    
    
    /// 发行中签查询
          /// 2.6
          /// 加载数据字典数组
          ///
          /// - parameter since_id:   返回ID比since_id大的微博（即比since_id时间晚的微博），默认为0
          /// - parameter max_id:     返回ID小于或等于max_id的微博，默认为0
          /// - parameter completion: 完成回调[list: 微博字典数组/是否成功]
          
          func issue_trade_query(session_id : String?, code : Array<Any>, finished : @escaping(_ result : [String : AnyObject]?, _ error : NSError?) -> ()) {
                 
              if session_id == nil {
                  print("请登陆")
                  return
              }
              
              // 1.获取请求的URLString
                 let urlString = "http://39.98.72.212:8006/index.php/Admin/Inter/index"
                 
                 // 2.获取请求的参数
              let parameters = ["method" : "phone", "xmlname" : "issue_trade_query","model":"直供申购手机端","data": code ] as [String : Any]
                 
                 // 3.发送网络请求
              request(methodType: .GET, URLString: urlString, parameters: parameters) { (result, error) -> () in
                  finished(result as? [String : AnyObject], error as NSError?)
                 }
             }
}
